package com.ft.turorial.spring.boot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;

import com.ft.turorial.spring.boot.servlet.MyServletByRegistrationBean;

@SpringBootApplication
@ServletComponentScan
public class SpringBoot04ServletApplication {

	/**
     * 使用代码注册Servlet（不需要@ServletComponentScan注解）
     *
     * @return
     * @author ft
     */
    @Bean
    public ServletRegistrationBean servletRegistrationBean() {
        return new ServletRegistrationBean(new MyServletByRegistrationBean(), "/ft/*");// ServletName默认值为首字母小写，即myServlet
    }
    
	public static void main(String[] args) {
		SpringApplication.run(SpringBoot04ServletApplication.class, args);
	}
}
